<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>错误处理机制</title>
</head>
<body>
    

    <script>
        
        // -> js 错误代码的处理机制

        try { // 可能出错的代码
            var a = [];
            console.log(b);
        } catch (error) { // 出错了怎么办
            console.log(error.message);
        } finally { // 出现finally  无论如何都会执行这里的代码
            console.log(a);
        }

    </script>
</body>
</html>